﻿<%@ include file="../include/top.jsp"%>
<%@ include file="../include/errorArea.jsp" %>
<link rel="stylesheet" href="${baseURL}/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script language="javascript" type="text/javascript" src="${baseURL}/js/jquery.ztree.all-3.5.min.js">
</script>
<script  type="text/javascript" src="${baseURL}/js/jquery.validate.js"></script>
<script  type="text/javascript" src="${baseURL}/js/jquery-1.8.3.js"></script>
<SCRIPT type="text/javascript">
	
	$('#print_button').click(function(){
		$('#printArea').printArea();
	});
</SCRIPT>
<div id="printArea">
<c:if test="${not empty receiveOrderList}">
<% int i=1;%>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="1" id="listOutTable">
  <tr>
    <td colspan="2" align="left" valign="middle" class="text_gray2">
    <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#96bee2">
      <tr>
        <td height="13" valign="top" bgcolor="#FFFFFF">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF" id="fieldTable" name="fieldTable">
<tr align="center" bgcolor="#eeeeee" id="0">
		<td class='userlist-td operation' height="25" width="70%">商品名称</td>
<!-- 	<td class='userlist-td operation' height="25" width="10%">库存数量</td> -->
		<td class='userlist-td operation' height="25" width="10%">销售数量</td>
	</tr>
	<c:forEach var="product" items="${receiveOrderList}">  
	<tr id="<%=i %>">
	<td class='userlist-td'>
	<input name='productId<%=i %>' id='productId<%=i %>' type="hidden" value=" ${product.productId}" size="25" style="width:50px;"/>
	<input name='communityId<%=i %>' id='communityId<%=i %>' type="hidden" value=" ${product.communityId}" size="25" style="width:50px;"/>
	 ${product.productName}
		    </td>
	<!--   <td class='userlist-td'>
		    <input name='stockNumber<%=i %>' id='stockNumber<%=i %>' type="hidden" value=" ${product.stockNumber}" size="25" style="width:50px;"/>
	 ${product.stockNumber}
		    </td> -->	  
		      <td class='userlist-td'>
		       <input name='productCount<%=i %>' id='productCount<%=i %>' type="hidden" value=" ${product.productCount}" size="25" style="width:50px;"/>
	 ${product.productCount}
		    </td>
		</tr> 
		   	<% i++;%>
                </c:forEach>
        </table>
        </td>
      </tr>
    </table></td>
  </tr>
</table>
</c:if>
<script type="text/javascript">
function changeReadyCount(){
	 var fieldList="";
        var fieldName="";
	error="";
	 $("#fieldTable tr").each(function(idx) {
	        // table1 下查找第 idx 个 tr，再查找 img
	        var trid=$("#fieldTable tr:eq(" + idx +")").attr("id");
	        if(trid!=0)
	        	{
	        	  var stock=$("#stockNumber" + trid).val();
	  	        var productId=$("#productId" + trid).val();
	  	        var communityId=$("#communityId" + trid).val();
	  		        var productCount=$("#productCount" + trid).val();
	  	        var sellNumber=$("#sellNumber" + trid).val();
	  			 if(isNaN(sellNumber)){
	  				error="请输入正确的销售数量。";
	  					return;
	  			 }
	  			 if( parseInt(sellNumber)>parseInt(productCount)||parseInt(sellNumber)>parseInt(stock)){
	  				error="大于销售数量或库存。";
	  					return;
	  			 }
	  			fieldName=productId+";"+sellNumber+";"+communityId;
	  			fieldList+=fieldName+"@";
	        	}
	      
	    });
	 if(error!="")
		 alert(error);
	 else{
		 $.ajax({
			   type: "POST",
			   async: false,
			   url: '${ctx}/supplierProduct/refundProduct?details='+fieldList+'&startTime=${formdata.startTime}',
			   success: function(data){
				   alert(data);
				   closeWin();
			}
		});
	 }
	 
}
</script>
</div>
<%@ include file="../include/bottom.jsp"%>